<template>
  <div class="signBoard">
    <vue-esign 
      ref="esign" 
      :width="signWidth" 
      :height="410" 
      :isCrop="isCrop" 
      :lineWidth="lineWidth" 
      :lineColor="lineColor"
      :isClearBgColor="false" 
      :bgColor.sync="bgColor"/>
    <div class="btnWrap">
      <div class="clearBtn" @click="handleReset">清 除</div> 
      <div class="confirmBtn" @click="handleGenerate">确 认</div>
    </div>
  </div>
</template>

<script>
// import { Toast } from "vant";
import vueEsign from 'vue-esign';
export default {
  name:'SignBoard',
  data(){
    return {
      lineWidth: 2,
      lineColor: '#000000',
      bgColor: '#ffffff',
      isCrop: false
    }
  },
  props:{
    signWidth:{
      type:Number,
      default:100
    },

  },
  components:{
    vueEsign
  },
  methods:{
    handleReset () {
      this.$refs.esign.reset()
    },
    handleGenerate () {
      this.$refs.esign.generate().then(res => {
        this.$emit('update:sendSignImg',res)
      }).catch(err => {
        Toast({message: '请先签名',className:'msgToast'});
      })
    }
  },
  mounted(){
   
  }
}
</script>

<style lang="scss" scoped>
@import "@/assets/css/common.scss";
.signBoard{
  width: 100%;
  height: 100%;
  padding-bottom: 0.5vw;
  box-sizing: border-box;
  .btnWrap{
    margin-top: 0.5vw;
    display: flex;
    justify-content: space-around;
    .confirmBtn{
      width: 30vw;
      height: 6.2vw;
      color: $white;
      border-radius: 1.5vw;
      line-height: 6.5vw;
      border: 1px solid #03B3FD;
      text-align: center;
      font-size: clamp($FontSize15, $FontSize15vw, $sysMaxFontSize);
      background: linear-gradient(135deg, #03B3FD 0%, #0083EF 100%);
    }
    .clearBtn{
      @extend .confirmBtn;
      color: $black;
      border: 1px solid #999999;
      background: $white;
    }
  }
}
</style>

<style lang='scss'>
.msgToast {
  background-color: #666666;
  line-height: 3vw;
  font-size: 3vw;
}
</style>